package com.mark.web.sys.entity.from;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @Description: 用户信息的表单验证
 * @Author: Mark
 * @CreateDate: 2018/7/27.
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Data
@ApiModel(value = "用户注册表单")
public class UserFrom {

    /**
     * 验证：用户名、手机号
     * 正则表达式
     */
    private static final String PHONE_REGEXP = "^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$";
    private static final String USERNAME_REGEXP = "^([A-Za-z0-9_])*$";

    /**
     * 用户ID
     */
    @ApiModelProperty(hidden = true)
    private Integer id;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名",required = true)
    @NotBlank(message = "用户名必填")
    @Pattern(regexp = USERNAME_REGEXP,message = "用户名只能包含数字、字母、下划线")
    @Length(min = 3,max = 15,message = "用户名的长度在3到15个字符")
    private String username;

    /**
     *密码
     */
    @ApiModelProperty(value = "密码",required = true)
    @NotBlank(message = "密码必填")
    @Length(min = 3,max = 20,message = "密码的长度在3到20个字符")
    private String password;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱",required = true)
    @NotBlank(message = "邮箱必填")
    @Email(message = "电子邮箱的格式不正确")
    private String email;

    /**
     * 手机号码
     */
    @ApiModelProperty(value = "手机号码",required = true)
    @NotBlank(message = "手机必填")
    @Pattern(regexp = PHONE_REGEXP)
    private String phone;

    /**
     * 用户头像
     */
    @ApiModelProperty(value = "用户头像")
    private String userImg;

    /**
     * 设置找回密码的问题
     */
    @ApiModelProperty(value = "问题")
    private String question;

    /**
     * 回答问题的答案
     */
    @ApiModelProperty(value = "答案")
    private String answer;

    /**
     * 性别
     */
    @ApiModelProperty(value = "性别",hidden = true)
    private String gender;

    /**
     * 状态
     */
    @ApiModelProperty(value = "状态",hidden = true)
    private Integer enableStatus;

    /**
     * 角色ID
     */
    @ApiModelProperty(value = "角色ID",hidden = true)
    private Integer fkRoleId;

    /**
     * 部门ID
     */
    @ApiModelProperty(value = "部门ID",hidden = true)
    private Integer fkDeptId;

}
